from rest_framework import serializers
from shopping.models import Product


class ProductSearchSerializer(serializers.Serializer):
    id = serializers.IntegerField(required=False)
    name = serializers.CharField(required=False, max_length=100)
    price = serializers.DecimalField(required=False, max_digits=10, decimal_places=2)
    description = serializers.CharField(required=False, max_length=500)
    stock = serializers.IntegerField(required=False)
    created_at = serializers.DateTimeField(required=False)
    updated_at = serializers.DateTimeField(required=False)

class ProductSerializer(serializers.ModelSerializer):
    class Meta:
        model = Product
        fields = ['id', 'name', 'price', 'description', 'stock', 'created_at', 'updated_at']